/*
  "name": "大山后台管理系统",
  "version": "1.0",
  "description": "大山中后台管理系统",
  "author": "大山",
  "date": "2023-04-04",
  "license": "MIT",
*/

const SUCCESS = 200, // 成功
  FAIL = 0,
  ERROR = 500, // 失败
  NOTFIND = 404,
  AUTHOR = 403;
module.exports = {
  config: {
    code: null,
    msg: null,
    data: null,
    success: null
  },
  init: function (data, msg, code) {
    (data) ? this.config.data = data : this.config.data = null;
    if (msg) this.config.msg = msg;
	console.log(code)
	if (code) this.config.code = code;
  },
  getSuccessResult: function (data, msg, code) {
    this.config.code = SUCCESS;
    this.config.msg = '请求成功';
    this.config.success = true;
    this.init(data, msg);
    return this.config;
  },
  getFailResult: function (data = '', msg, code) {
    this.config.code = code ? code : ERROR;
    this.config.msg = '请求失败';
    this.config.success = false
    this.init(data, msg);
    return this.config;
  }
}